package com.gsc.demo.dao;

import com.gsc.demo.model.User;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

import javax.persistence.Query;

/**
 * file description
 * Created by 72038967 on 2019/8/12.
 */
@Repository
public class UserImp implements IUserDao {

    @Autowired
    private SessionFactory sessionFactory;

    private Session getCurrentSession() {
        return this.sessionFactory.openSession();
    }


    public List<User> selectAll() {


        Query q = getCurrentSession().createSQLQuery("select * from table_yg").addEntity(User.class);
        List<User> rs = q.getResultList();
        return rs;
    }
}
